import { _decorator, Component, Node, Prefab, CCFloat } from 'cc';
import { poolManager } from '../../../../Framework/Scripts/Managers/poolManager';
import { GameApp } from '../../GameApp';
import { enemyBase } from '../enemyBase';
import { FireBall } from '../enemySkill/fireBall';
import { playerBase } from '../playerBase';

import { Missile } from '../weaponCtrl/missile';
const { ccclass, property } = _decorator;


/** 
  周无邪出品
  本源码用于学习研究使用。
  作者联系方式：tuya7078（微信）。
 */
@ccclass('aula')
export class aula extends enemyBase {
    @property(Prefab)
    public pfWeapon: Prefab = null!;//武器预制体
    @property(Node)
    public ndRightHand: Node = null!;//右手节点

    @property({ type: Number, displayName: "狂暴百分比" })
    protected kuangbao: number = 0.5

    @property({ type: CCFloat, displayName: "狂暴后的攻击范围" })
    protected kuangbaoAttackRange: number = 20

    private hitNum2=30//激光攻击默认伤害
    onLoad(){
       super.onLoad()
        this.kuangbaoAttackRange*= this.kuangbaoAttackRange
    }

    start() {

    }

        
        

    
    attack() {
        super.attack()
       // this.NavTs.StopNav()
        this.node.lookAt(this.attackTarget.getWorldPosition())

        this.enemyModel.playAni(this.attackAni1, true)



    }

    public attickCallback() { 

        if(this.isKuangbao){
            const n:Node=poolManager.instance.getNode(this.pfWeapon, GameApp.Instance.skillRoot)
            n.setWorldPosition(this.ndRightHand.worldPosition)
          
          
            
            let ts: FireBall = n.getComponent(FireBall)
    
         
            
         
            if (ts) {
             
     
               ts.init(this.hitNum2,this.ndRightHand.getWorldPosition(),this.attackTarget.getWorldPosition(),3,this.node)
            }
        }else{
            this.putonggognji()
        }
     
          
     
    }//攻击回调

    
    hit(num: number,how:Node) {
        super.hit(num,how)
        if(this.hp/this.totalHP<=this.kuangbao){
             this.isKuangbao=true
             this.nowAttackRange=this.kuangbaoAttackRange
        }




    }
    update(dt: number) {

        super.update(dt)
        
    }
}


